package 创建型模式.单例;

/**
 * @ClassNameLazySingleton
 * @Description
 * @Author
 * @Date2021/11/17 20:39
 **/

/***
 * 懒汉式
 * @author zwzh_zj
 */
public class LazySingleton {
    private static volatile LazySingleton lazySingleton = null;

    private LazySingleton() {
        //private 避免类在外部被实例化?
    }

    public synchronized LazySingleton getInstance() {
        if (lazySingleton == null) {
            lazySingleton = new LazySingleton();
        }
        return lazySingleton;
    }
}
